import 'package:mobx/mobx.dart';
import '../serialized/detail.dart';

part 'video_page_state.g.dart';

class VideoPageHoistedState = _VideoPageHoistedStateBase
    with _$VideoPageHoistedState;

// 影片页组件提升状态
abstract class _VideoPageHoistedStateBase with Store {
  @observable
  DetailSerializedGen detail = DetailSerializedGen(); // 详情可观察数据

  @observable
  bool detailIsFavorite = false; // 详情页数据是否收藏

  @observable
  bool detailisLike = false; // 详情页数据是否点赞

  // 请求数据并初始化状态
  @action
  void setUpDetail(DetailSerializedGen newDetail) {
    // 拿到数据之后，如果数据有效则更新状态
    if (newDetail != null) {
      detail = newDetail;
      detailIsFavorite = newDetail.isFavorite;
      detailisLike = newDetail.isLike;
      print('detail字段数据已更新');
    }
  }

  // 设置是否收藏
  @action
  void setDetailIsFavorite(bool value) {
    detailIsFavorite = value;
  }

  // 设置是否点赞
  @action
  void setDetailIsLike(bool value) {
    detailisLike = value;
  }

}
